package edu.lingnan.house.controller;

import edu.lingnan.house.pojo.TbUser;
import edu.lingnan.house.service.HostService_lxj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class HostController_lxj {
    @Autowired
    private HostService_lxj hostService;

    //房主查找个人信息
    /*@GetMapping("/h1")
    @ResponseBody
    public TbUser testFindSelf(String userId){
        TbUser user = hostService.findSelfById(userId);
        return user;
    }*/
    @GetMapping("/s1")
    @ResponseBody
    public TbUser h1(HttpSession session){
        TbUser tbUser = (TbUser) session.getAttribute("tbUser");
        TbUser user = hostService.findSelfById("187");
        return user;


    }

    //房主修改个人信息
    @PostMapping("/h2")
    @ResponseBody
    public String testUpdateHost(@RequestBody TbUser user){
        int row = hostService.updateMySelf(user);
        return "ok";
    }
}
